package com.wbcs.config.template.tags;

import com.wbcs.exception.WbcsRuntimeException;
import com.wbcs.system.ReportRequest;
import com.wbcs.system.assistant.TagAssistant;
import com.wbcs.system.component.AbsComponentType;
import com.wbcs.system.component.application.report.abstractreport.AbsReportType;
import com.wbcs.util.Consts_Private;

public class SNavigateTag extends AbsTagInTemplate
{
    public SNavigateTag(AbsTagInTemplate parentTag)
    {
        super(parentTag);
    }

    @Override
	public String getTagname()
    {
        return Consts_Private.TAGNAME_NAVIGATE;
    }

    @Override
	public String getDisplayValue(ReportRequest rrequest,AbsComponentType ownerComponentObj)
    {
        AbsComponentType displayComponentObj=this.getDisplayComponentObj(rrequest);
        if(displayComponentObj==null) displayComponentObj=ownerComponentObj;
        if(!(displayComponentObj instanceof AbsReportType))
        {
            throw new WbcsRuntimeException("组件"+displayComponentObj.getConfigBean().getPath()+"不是报表，不能调用<wx:navigate/>显示其翻页导航栏部分");
        }
        String type=null;
        String minlength=null;
        String initcount=null;
        String maxcount=null;
        String top=null;
        if(this.mTagAttributes!=null)
        {
            type=this.mTagAttributes.get("type");
            type=type==null?"":type.toLowerCase().trim();
            minlength=this.mTagAttributes.get("minlength");
            initcount=this.mTagAttributes.get("initcount");
            maxcount=this.mTagAttributes.get("maxcount");
            top=this.mTagAttributes.get("top");
        }
        return TagAssistant.getInstance().getNavigateDisplayInfo((AbsReportType)displayComponentObj,type,minlength,
                initcount,maxcount,top,this.tagContent);
    }
}
